package com.baizhi.shane.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baizhi.shane.sys.entity.SysRole;
import com.baizhi.shane.sys.service.SysRoleService;
import com.baizhi.shane.sys.mapper.SysRoleMapper;
import org.springframework.stereotype.Service;

/**
* @author wbz12
* @description 针对表【sys_role(角色表)】的数据库操作Service实现
* @createDate 2023-03-26 18:19:03
*/
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole>
    implements SysRoleService{

    /**
     * 通过roleCode获取角色对象
     *
     * @Author 闻柏智
     * @Date 22:32 2023/3/29
     * @Param roleCode
     * @return com.baizhi.baiweiexam.sys.entity.SysRole
     **/
    @Override
    public SysRole getRoleByRoleCode(String roleCode) {
        LambdaQueryWrapper<SysRole> qwSr = new LambdaQueryWrapper<>();
        qwSr.eq(SysRole::getRoleCode,roleCode);
        SysRole sysRole = this.getOne(qwSr);
        return sysRole;
    }

    /**
     * 通过roleCode获取角色ID
     *
     * @Author 闻柏智
     * @Date 22:40 2023/3/29
     * @Param roleCode
     * @return long
     **/
    @Override
    public long getRoleIdByRoleCode(String roleCode) {
        SysRole sysRole = this.getRoleByRoleCode(roleCode);
        long id = sysRole.getId();
        return id;
    }
}




